package com.heima.admin.task;

import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Slf4j
//@Component
public class MyTask {

    int count=0;
//    @Scheduled(cron = "*/3 * * * * *") //cron表达式
//    @Scheduled(fixedDelay = 2000)  //固定延迟
    @Scheduled(fixedRate = 2000)
    public void task() throws InterruptedException {
        log.info("====定时任务执行了");
        if(count==2){
            Thread.sleep(3000);
        }
        count ++;
    }
}
